from django.db import models
from .classinfo import ClassInfo  # 假设ClassInfo是班级模型，根据实际项目调整
from .base_model import BaseModel
from django.utils import timezone


class ClassTaskTodo(BaseModel):
    created_at = models.DateTimeField(default=timezone.now, verbose_name="创建时间")
    class Meta:
        verbose_name = '班级待办事务'
        verbose_name_plural = '班级待办事务'
        ordering = ['-start_time']

    class_info = models.ForeignKey(
        ClassInfo,
        on_delete=models.CASCADE,
        verbose_name='所属班级',
        help_text='选择关联的班级'
    )
    start_time = models.DateTimeField('开始时间')
    end_time = models.DateTimeField('截止时间')
    content = models.TextField('待办内容', help_text='详细描述待办事项')
    is_completed = models.BooleanField('是否处理', default=False, help_text='标记事务处理状态')
    handling_measures = models.TextField('处理措施', blank=True, null=True, help_text='记录已采取的处理方法')

    def __str__(self):
        return f'{self.class_info} - {self.content[:20]}'  # 显示前20个字符避免过长